﻿using System.Collections.Generic;
using System.Xml.Linq;
using Net.Chirash.Twitter.TwitterDatabase;

namespace Net.Chirash.Twitter.TwitterClient
{
    public class Timeline
        : TwitterDataCollection<Status>
    {
        #region Public Constructors

        public Timeline(IEnumerable<Status> statuses)
            : base(statuses)
        {
        }

        public Timeline()
            : this(new Status[0])
        { }

        #endregion

        //#region Public Properties

        //public List<Status> Statuses { get; set; }

        //#endregion

        #region Public Methods

        /// <summary>
        /// Load an Net.Chirash.Twitter.TwitterClient.Timeline from xml that contains html encoded xml
        /// </summary>
        /// <param name="xml">HTML Encoded XML</param>
        /// <returns></returns>
        public static Timeline Parse(string xml, ITwitterCommand cmd)
        {
            List<Status> list = new List<Status>();
            foreach (XElement element in XElement.Parse(xml).Elements("status"))
            {
                list.Add(new Status().Parse(element.ToString(), cmd));
            }
            return new Timeline(list);
        }

        #endregion
    }
}
